<?php
class User_Form_FreeSignup extends Custom_Form
{
    public function init()
    {
        $translate = Zend_Registry::get('translate');
        $passwordConfirmation = new Custom_Validate_PasswordConfirmation();
      

        $this->setName("signup");
        $this->setMethod('post');

        $this->addElement('text', 'user_fullname', 
                                   array('label' => $translate->_('Name'),
                                         'required' => true,
                                         'filters'=> array('StringTrim'),
                                       
            'validators' => array(array('StringLength', false, array(0, 50)))
        ));


        $this->addElement('text', 'user_email', 
                        array('label' => $translate->_('Email Address'), 
                              'required' => 'true',
                              'filters'=> array('StringTrim'),
                              'validators' => array(array('EmailAddress')),
                              array('Db_NoRecordExists',false,
                              array('table'=>'viz_user','field'=>'user_email'))));
        
        $this->addElement('text', 'username', 
                            array('label' => $translate->_('Username'), 
                                  'required' => 'true',
                                  'filters'=> array('StringTrim'),
                                   array('Db_NoRecordExists',false,
                                   array('table'=>'viz_user',
                                         'field'=>'username'))));
        
        $this->addElement('password', 'password',
                           array('label' => $translate->_('Password'),
                                 'required' => 'true',
                                 'filters'=> array('StringTrim')));
        
        $this->addElement('password', 'password_confirm',
                                      array('label' => $translate->_('Confirm password'),
                                            'required' => 'true',
                                            'validators'=>array($passwordConfirmation)));

        $this->addElement('text', 'user_phone',
                                   array('label' => $translate->_('Phone Number'),
                                         'required' => 'true',
                                         'filters'=> array('StringTrim')));

        $this->addElement('submit', 'submit', 
                                    array('ignore' => true,
                                         'required' => false,
                                          'lable'=>$translate->_('Register'),
                                        ));

        $element = $this->getElement('submit');
        $element->removeDecorator('label');
        
        

        
        
        $this->user_fullname->addErrorMessage($translate->_('ERR_SIGNUP_FULLNAME'));
        $this->user_email->addErrorMessage($translate->_('ERR_SIGNUP_EMAIL'));
        $this->username->addErrorMessage($translate->_('ERR_SIGNUP_USERNAME'));
        $this->password->addErrorMessage($translate->_('ERR_SIGNUP_PASSWORD'));
        $this->password_confirm->addErrorMessage($translate->_('ERR_SIGNUP_CONFIRMPASSWORD'));
        $this->user_phone->addErrorMessage($translate->_('ERR_SIGNUP_PHONE'));
        
    }
    
   
    
}
?>
